/*
 * Copyright (C), 2002-2017, 上海巧房信息技术有限公司 FileName: Tables.java Author: jason
 * Date: Sep 12, 2017 3:52:20 PM Description: //模块目的、功能描述 History: //修改记录
 * <author> <time> <version> <desc> 修改人姓名 修改时间 版本号 描述
 */
package com.example.myproject.util;

import java.util.Arrays;
import java.util.Optional;

/**
 * 〈一句话功能简述〉<br>
 * 〈功能详细描述〉
 *
 * @author jason
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
public enum MappingTable {
    BPM_WORKFLOW_DEF("bpm_workflow_def", "defId", "defUuid"),
    BPM_WORKFLOW_FORM("bpm_workflow_form", "formId", "formUuid"),
    BPM_WORKFLOW_FORM_DATA("bpm_workflow_form_data", "formDataId", "formDataUuid"),
    BPM_WORKFLOW_FORM_TYPE("bpm_workflow_form_type", "formTypeId", "formTypeUuid"),
    BPM_WORKFLOW_INSTANCE("bpm_workflow_instance", "instanceId", "instanceUuid"),
    BPM_WORKFLOW_LIMIT("bpm_workflow_limit", "limitId", "limitUuid"),
    BPM_WORKFLOW_METADATA("bpm_workflow_metadata", "metadataId", "metadataUuid"),
    BPM_WORKFLOW_METADATASET("bpm_workflow_metadataset", "metadatasetId", "metadatasetUuid"),
    BPM_WORKFLOW_NOTICE("bpm_workflow_notice", "noticeId", "noticeUuid"),
    BPM_WORKFLOW_TYPE("bpm_workflow_type", "typeId", "typeUuid"),
    BPM_WORKFLOW_USERSET("bpm_workflow_userset", "usersetId", "usersetUuid"),
    COM_AREA("com_area", "areaId", "areaUuid"),
    COM_BRAND_EVENT_TEMPLATE("com_brand_event_template", "betId", "betUuid"),
    COM_BRAND_EVENT_TEMPLATE_PROPERTY("com_brand_event_template_property", "betpId", "betpUuid"),
    COM_BRAND_EVENT_TEMPLATE_VALUE("com_brand_event_template_value", "betvId", "betvUuid"),
    COM_BUILDING("com_building", "buildingId", "buildingUuid"),
    COM_CONTACT("com_contact", "contactId", "contactUuid"),
    COM_DISTRICT("com_district", "districtId", "districtUuid"),
    COM_ESTATE("com_estate", "estateId", "estateUuid"),
    COM_ESTATEPHOTO("com_estatephoto", "photoId", "photoUuid"),
    COM_PHOTOCATEGORY("com_photocategory", "categoryId", "categoryUuid"),
    COM_LOG("com_log", "logId", "logUuid"),
    COM_ROOM("com_room", "roomId", "roomUuid"),
    CT_CONTRACT("ct_contract", "contractId", "contractUuid"),
    CT_DISTRIBUTION("ct_distribution", "distributionId", "distributionUuid"),
    ORG_DEPARTMENT("org_department", "deptId", "deptUuid"),
    ORG_EMPLOYEE("org_employee", "employeeId", "employeeUuid"),
    ORG_POSITION("org_position", "positionId", "positionUuid"),
    ORG_USERCONTACT("org_usercontact", "contactId", "contactUuid"),
    PRO_CUSTOMER("pro_customer", "customerId", "customerUuid"),
    PRO_CUSTOMER_FOLLOW("pro_customer_follow", "followId", "followUuid"),
    PRO_EXPLAIN("pro_explain", "explainId", "explainUuid"),
    PRO_FOLLOW("pro_follow", "followId", "followUuid"),
    PRO_INSPECTIONAFFIX("pro_inspectionaffix", "affixId", "affixUuid"),
    PRO_INSPECTIONRECORD("pro_inspectionrecord", "recordId", "recordUuid"),
    PRO_OTHER_FOLLOW("pro_other_follow", "followId", "followUuid"),
    PRO_PROPERTY("pro_property", "propertyId", "propertyUuid"),
    PRO_PROPERTY_CARD("pro_property_card", "cardId", "cardUuid"),
    PRO_PROPERTY_FOLLOW("pro_property_follow", "followId", "followUuid"),
    PRO_PROPERTY_KEY("pro_property_key", "keyId", "keyUuid"),
    PRO_PROPERTY_KEY_LOG("pro_property_key_log", "logId", "logUuid"),
    PRO_PROPERTYADDRESS("pro_propertyaddress", "addressId", "addressUuid"),
    PRO_PROPERTYPHOTO("pro_propertyphoto", "photoId", "photoUuid"),
    PRO_PROPERTYSURVEY("pro_property_survey", "surveyId", "surveyUuid"),
    PRO_PROPERTYSURVEYSPACE("pro_property_survey_space", "surveyId", "surveyUuid"),
    SYS_ESTATE_SUBWAY("sys_estate_subway", "estateSubwayId", "estateSubwayUuid"),
    SYS_FIELD("sys_field", "fieldId", "fieldUuid"),
    SYS_NOTICE("sys_notice", "noticeId", "noticeUuid"),
    SYS_SYSTEMCONFIG("sys_systemconfig", "configId", "configUuid"),
    SYS_NOTICERECEIVER("sys_noticereceiver","srId","srUuId"),
    TG_TRENT("tg_trent", "trentId", "trentUuid"),
    TG_TRUST("tg_trust", "trustId", "trustUuid"),
    TK_BLACKLIST("tk_blacklist", "blackId", "blackUuid"),
    TK_MESSAGE("tk_message", "messageId", "messageUuid"),
    TK_NEWS("tk_news", "newsId", "newsUuid"),
    TK_TASK("tk_task", "taskId", "taskuuid"),
    TK_SUMMARY("tk_summary", "summaryId", "summaryUuid"),
    TX_CHARGE_CATEGORY("tx_charge_category", "chargeId", "chargeUuid"),
    TX_DISTRIBUTION("tx_distribution", "distributionId", "distributionUuid"),
    TX_FLOW("tx_flow", "flowId", "flowUuid"),
    TX_FLOWDEF("tx_flowDef", "flowDefId", "flowDefUuid"),
    TX_FLOWTYPE("tx_flowType", "typeId", "typeUuid"),
    TX_REALPAYMENTDETAIL("tx_realpaymentdetail", "detailId", "detailUuid"),
    TX_REALPAYMENTDETAIL_CALCOMMISSION("tx_realpaymentdetail_calcommission", "detailId", "detailUuid"),
    TX_TRANSACTION("tx_transaction", "txId", "txUuid"),
    COM_PROPERTY_CONTACT("com_property_contact","contactId","contactUuid"),
    ORG_BUSINESSCALL_EMP("org_businessCall_emp","bcId","bcUuid"),
    C_CALLRECORD("c_callrecord","recordId","recordUuid"),
    ORG_USER_FAVORITES("org_user_favorites","favoriteId","favoriteUuid"),
    ;
    private String name;
    private String idColumn;
    private String uuidColumn;

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name
     *            the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the idColumn
     */
    public String getIdColumn() {
        return idColumn;
    }

    /**
     * @param idColumn
     *            the idColumn to set
     */
    public void setIdColumn(String idColumn) {
        this.idColumn = idColumn;
    }

    /**
     * @return the uuidColumn
     */
    public String getUuidColumn() {
        return uuidColumn;
    }

    /**
     * @param uuidColumn
     *            the uuidColumn to set
     */
    public void setUuidColumn(String uuidColumn) {
        this.uuidColumn = uuidColumn;
    }

    /**
     * @param name
     * @param idColumn
     * @param uuidColumn
     */
    private MappingTable(String name, String idColumn, String uuidColumn) {
        this.name = name;
        this.idColumn = idColumn;
        this.uuidColumn = uuidColumn;
    }

    public static MappingTable nameOf(String name) {
        Optional<MappingTable> ts = Arrays.asList(MappingTable.values()).stream().filter(item -> {
                    return item.getName().equals(name);
                }).findFirst();
        if(ts.isPresent()) {
            return ts.get();
        }
        return null;
    }
}
